﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LongSpeed.WebSite.Main.Admin
{
    public partial class WebSiteConfig : Behaviors.Session
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (AdminDeskTop.SiteConfig == null)
                {
                    AdminDeskTop.SiteConfig = new Behaviors.WebSiteConfig();
                    AdminDeskTop.SiteConfig = AdminDeskTop.SiteConfig.Init(this.Server);
                }
                this.txtAdd.Text = AdminDeskTop.SiteConfig.Address;
                this.txtContactPhone.Text = AdminDeskTop.SiteConfig.ContactPhone;
                this.txtCopyright.Text = AdminDeskTop.SiteConfig.Copyright;
                this.txtDescription.Text = AdminDeskTop.SiteConfig.Description;
                this.txtKeyWords.Text = AdminDeskTop.SiteConfig.KeyWords;
                this.txtTitle.Text = AdminDeskTop.SiteConfig.Tilte;
            }
        }

        [Ext.Net.DirectMethod]
        public void SaveConfig(object obj)
        {
            Ext.Net.JsonReader jo = new Ext.Net.JsonReader();
            var config = Newtonsoft.Json.JsonConvert.DeserializeObject(obj.ToString(), typeof(Behaviors.WebSiteConfig)) as Behaviors.WebSiteConfig;
            config.Save(this);

            AdminDeskTop.SiteConfig = config;
        }
    }
}